package loveqq.niceexcel.core.metadata;

import loveqq.niceexcel.annotation.format.NumberFormat;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

import java.math.RoundingMode;

/**
 * 数字格式化
 *
 * @author zhongjh@tsintergy.com
 * @date 2022-08-26
 */
@Setter
@Getter
@RequiredArgsConstructor
public class NumberFormatData {
    /**
     * 格式
     */
    private final String format;
    /**
     * 舍入模式
     */
    private final RoundingMode roundingMode;


    public static NumberFormatData build(NumberFormat numberFormat) {
        if (numberFormat == null) {
            return null;
        }
        return new NumberFormatData(numberFormat.value(), numberFormat.roundingMode());
    }

}
